DOORS to RTC work item calls

I am trying to interface DOORS with RTC using DXL. The method I have tried is using CURL to transfer the commands to RTC with batch files for each of the operations for PUT and GET. When using the system call System(cmdString) this works fine except I have no way of monitoring the DOS window for when it closes. I have tried using the win32SystemWait_ function which is OK for the GET statement but when using the PUT function, windows crashes out without any indication of the cause. Has anyone successfully interfaced with RTC work items using DOORS 9.5? any help would be appreciated.
SystemAdmin - Mon Mar 25 11:50:53 EDT 2013

Re: DOORS to RTC work item calls
SystemAdmin - Mon Mar 25 12:57:18 EDT 2013

error in text above, "when using the PUT function, windows crashes out without any indication of the cause" should have read DOORS crashes out

Re: DOORS to RTC work item calls
Richard_Good - Mon Mar 25 14:30:42 EDT 2013

SystemAdmin - Mon Mar 25 12:57:18 EDT 2013
error in text above, "when using the PUT function, windows crashes out without any indication of the cause" should have read DOORS crashes out

DOORS is connected to RTC, but via a very convoluted ham fisted method in my opinion. I would be tempted to use DOORS Next Gen instead of DOORS if you are just starting out on these activities. Also, why use the web message route, why not try the command line instead see http://pic.dhe.ibm.com/infocenter/clmhelp/v3r0/index.jsp?topic=%2Fcom.ibm.team.scm.doc%2Ftopics%2Fr_scm_cli_scm.html
Regards,

Richard

Re: DOORS to RTC work item calls
Mathias Mamsch - Mon Mar 25 16:19:58 EDT 2013

Instead of using Win32SystemWait_ you can use the shell com object. Here is some old library I did once. Maybe it helps, regards, Mathias
 

pragma runLim, 0
 
const string m_shell_handle       = "handle"
const string m_shell_cmd          = "cmd"
 
struct Shell {}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DxlObject DxlObjectOf(Shell p) { return (addr_ p) DxlObject }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void check_shell_res(string s) {
    if (!null s) error "SHELL: executing command failed with following error - " s
}
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void delete(Shell p) {
        DxlObject x = DxlObjectOf p; 
        
        delete x; 
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OleAutoObj ShellObject (Shell x) {
        DxlObject obj = DxlObjectOf x
        OleAutoObj result = (obj->m_shell_handle) OleAutoObj
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// if getOutput is called, it will return only when the command has ended.
string getOutput (Shell x) {
        OleAutoObj obj = ShellObject x
        OleAutoObj stdout
        OleAutoArgs args = create()
        
        string result 
        
        check_shell_res oleGet(obj, "StdOut", stdout) 
        
        string printOut
        check_shell_res oleMethod (stdout, "ReadAll", args, result)   
                
        delete args
        
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int getIntProperty(Shell x, string name) {
        OleAutoObj obj = ShellObject x
        
        int result = 0
        
        check_shell_res oleGet(obj, name, result )
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Status 0 = running     Status 1 = finished      Status 2 = failed 
int status    (Shell x) { return getIntProperty(x, "Status")    }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int exitCode  (Shell x) { return getIntProperty(x, "ExitCode")  }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int processID (Shell x) { return getIntProperty(x, "ProcessID") }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void terminate(Shell x) { 
        OleAutoObj obj = ShellObject x
        
        check_shell_res oleMethod (obj, "Terminate")
}
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// if wait is true the script will wait for the process to end
Shell create(string cmd, bool wait) {
        DxlObject x = new; 
        
        x->m_shell_cmd       = ""
        x->m_shell_handle    = null OleAutoObj
 
        OleAutoObj shellObj = oleCreateAutoObject "WScript.Shell"
        OleAutoObj result = null
        
        OleAutoArgs args = create()
        
        put(args, cmd)
        
        check_shell_res oleMethod(shellObj, "Exec", args, result) 
        
        while (true && wait) {
                int status
                
                check_shell_res oleGet(result, "Status", status)
                
                if (status != 0) break
 
                sleep_ 50
        }    
        
        int intVar
        string var
        
        x->m_shell_cmd       = cmd
        x->m_shell_handle    = result
                
        return addr_ x
}
 
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void test () {
 
        print "Starting NotePad"
 
        Shell npad = create ("Notepad.exe", false)
 
        print "Listing a directory ... don't close Nodepad!"
 
        Shell cmd  = create ("cmd.exe /C dir M:\\", true) 
 
        print "Output from cmd.exe:\n" getOutput cmd "\n"
        
        sleep_ 1000
 
        terminate npad
        
        print "Nodepad Exit Code = " exitCode npad "\n"
        print "Nodepad Status = " status npad "\n"
 
        print "Doing something that will return an error:\n"
 
        cmd  = create ("cmd.exe /C copy 123", true) 
 
        print "Exit Code:" (exitCode cmd) "\n"
        print "Status   :" (status cmd) "\n"
 
}

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: DOORS to RTC work item calls
SystemAdmin - Tue Mar 26 05:49:01 EDT 2013

Richard_Good - Mon Mar 25 14:30:42 EDT 2013
DOORS is connected to RTC, but via a very convoluted ham fisted method in my opinion. I would be tempted to use DOORS Next Gen instead of DOORS if you are just starting out on these activities. Also, why use the web message route, why not try the command line instead see http://pic.dhe.ibm.com/infocenter/clmhelp/v3r0/index.jsp?topic=%2Fcom.ibm.team.scm.doc%2Ftopics%2Fr_scm_cli_scm.html
Regards,

Richard

Hi Richard, Thanks for your reply, DOORS next is not an option for this database project so I have to work with what I have. The web message route is the only way I have found to manipulate the planning side of the RTC work items which uses the OSLC implementation. Your suggestion for using the command line only applies to the SCM side so again I am stuck with my rather clunky solution.

Re: DOORS to RTC work item calls
SystemAdmin - Tue Mar 26 06:00:16 EDT 2013

Mathias Mamsch - Mon Mar 25 16:19:58 EDT 2013

Instead of using Win32SystemWait_ you can use the shell com object. Here is some old library I did once. Maybe it helps, regards, Mathias
 

pragma runLim, 0
 
const string m_shell_handle       = "handle"
const string m_shell_cmd          = "cmd"
 
struct Shell {}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DxlObject DxlObjectOf(Shell p) { return (addr_ p) DxlObject }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void check_shell_res(string s) {
    if (!null s) error "SHELL: executing command failed with following error - " s
}
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void delete(Shell p) {
        DxlObject x = DxlObjectOf p; 
        
        delete x; 
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OleAutoObj ShellObject (Shell x) {
        DxlObject obj = DxlObjectOf x
        OleAutoObj result = (obj->m_shell_handle) OleAutoObj
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// if getOutput is called, it will return only when the command has ended.
string getOutput (Shell x) {
        OleAutoObj obj = ShellObject x
        OleAutoObj stdout
        OleAutoArgs args = create()
        
        string result 
        
        check_shell_res oleGet(obj, "StdOut", stdout) 
        
        string printOut
        check_shell_res oleMethod (stdout, "ReadAll", args, result)   
                
        delete args
        
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int getIntProperty(Shell x, string name) {
        OleAutoObj obj = ShellObject x
        
        int result = 0
        
        check_shell_res oleGet(obj, name, result )
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Status 0 = running     Status 1 = finished      Status 2 = failed 
int status    (Shell x) { return getIntProperty(x, "Status")    }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int exitCode  (Shell x) { return getIntProperty(x, "ExitCode")  }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int processID (Shell x) { return getIntProperty(x, "ProcessID") }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void terminate(Shell x) { 
        OleAutoObj obj = ShellObject x
        
        check_shell_res oleMethod (obj, "Terminate")
}
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// if wait is true the script will wait for the process to end
Shell create(string cmd, bool wait) {
        DxlObject x = new; 
        
        x->m_shell_cmd       = ""
        x->m_shell_handle    = null OleAutoObj
 
        OleAutoObj shellObj = oleCreateAutoObject "WScript.Shell"
        OleAutoObj result = null
        
        OleAutoArgs args = create()
        
        put(args, cmd)
        
        check_shell_res oleMethod(shellObj, "Exec", args, result) 
        
        while (true && wait) {
                int status
                
                check_shell_res oleGet(result, "Status", status)
                
                if (status != 0) break
 
                sleep_ 50
        }    
        
        int intVar
        string var
        
        x->m_shell_cmd       = cmd
        x->m_shell_handle    = result
                
        return addr_ x
}
 
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void test () {
 
        print "Starting NotePad"
 
        Shell npad = create ("Notepad.exe", false)
 
        print "Listing a directory ... don't close Nodepad!"
 
        Shell cmd  = create ("cmd.exe /C dir M:\\", true) 
 
        print "Output from cmd.exe:\n" getOutput cmd "\n"
        
        sleep_ 1000
 
        terminate npad
        
        print "Nodepad Exit Code = " exitCode npad "\n"
        print "Nodepad Status = " status npad "\n"
 
        print "Doing something that will return an error:\n"
 
        cmd  = create ("cmd.exe /C copy 123", true) 
 
        print "Exit Code:" (exitCode cmd) "\n"
        print "Status   :" (status cmd) "\n"
 
}

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Hi Mathias, Thanks for the library routines, I still have an issue with the put function not working correctly so I will need to dig further but I do have a working solution now so panic over, just need to tidy it up so that it looks more professional.

Re: DOORS to RTC work item calls
llandale - Tue Mar 26 12:02:31 EDT 2013

Mathias Mamsch - Mon Mar 25 16:19:58 EDT 2013

Instead of using Win32SystemWait_ you can use the shell com object. Here is some old library I did once. Maybe it helps, regards, Mathias
 

pragma runLim, 0
 
const string m_shell_handle       = "handle"
const string m_shell_cmd          = "cmd"
 
struct Shell {}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DxlObject DxlObjectOf(Shell p) { return (addr_ p) DxlObject }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void check_shell_res(string s) {
    if (!null s) error "SHELL: executing command failed with following error - " s
}
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void delete(Shell p) {
        DxlObject x = DxlObjectOf p; 
        
        delete x; 
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OleAutoObj ShellObject (Shell x) {
        DxlObject obj = DxlObjectOf x
        OleAutoObj result = (obj->m_shell_handle) OleAutoObj
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// if getOutput is called, it will return only when the command has ended.
string getOutput (Shell x) {
        OleAutoObj obj = ShellObject x
        OleAutoObj stdout
        OleAutoArgs args = create()
        
        string result 
        
        check_shell_res oleGet(obj, "StdOut", stdout) 
        
        string printOut
        check_shell_res oleMethod (stdout, "ReadAll", args, result)   
                
        delete args
        
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int getIntProperty(Shell x, string name) {
        OleAutoObj obj = ShellObject x
        
        int result = 0
        
        check_shell_res oleGet(obj, name, result )
        return result
}
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Status 0 = running     Status 1 = finished      Status 2 = failed 
int status    (Shell x) { return getIntProperty(x, "Status")    }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int exitCode  (Shell x) { return getIntProperty(x, "ExitCode")  }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int processID (Shell x) { return getIntProperty(x, "ProcessID") }
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void terminate(Shell x) { 
        OleAutoObj obj = ShellObject x
        
        check_shell_res oleMethod (obj, "Terminate")
}
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// if wait is true the script will wait for the process to end
Shell create(string cmd, bool wait) {
        DxlObject x = new; 
        
        x->m_shell_cmd       = ""
        x->m_shell_handle    = null OleAutoObj
 
        OleAutoObj shellObj = oleCreateAutoObject "WScript.Shell"
        OleAutoObj result = null
        
        OleAutoArgs args = create()
        
        put(args, cmd)
        
        check_shell_res oleMethod(shellObj, "Exec", args, result) 
        
        while (true && wait) {
                int status
                
                check_shell_res oleGet(result, "Status", status)
                
                if (status != 0) break
 
                sleep_ 50
        }    
        
        int intVar
        string var
        
        x->m_shell_cmd       = cmd
        x->m_shell_handle    = result
                
        return addr_ x
}
 
 
 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void test () {
 
        print "Starting NotePad"
 
        Shell npad = create ("Notepad.exe", false)
 
        print "Listing a directory ... don't close Nodepad!"
 
        Shell cmd  = create ("cmd.exe /C dir M:\\", true) 
 
        print "Output from cmd.exe:\n" getOutput cmd "\n"
        
        sleep_ 1000
 
        terminate npad
        
        print "Nodepad Exit Code = " exitCode npad "\n"
        print "Nodepad Status = " status npad "\n"
 
        print "Doing something that will return an error:\n"
 
        cmd  = create ("cmd.exe /C copy 123", true) 
 
        print "Exit Code:" (exitCode cmd) "\n"
        print "Status   :" (status cmd) "\n"
 
}

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

You know that win32Wait command has never worked for me.

I'm a little slow on the update here so don't be offended by these questions:
  • I can use this, with "wait = true", to replace win32Wait?
  • should not function "delete(Shell p)" also delete the OleAutoObj?
  • could not function "terminate(Shell x)" see if it already terminated?
  • What are the "ExitCode"s?
  • if the command has finished, will status(), exitCode(), and processID() still work?

  • Could you do away with "Struct Shell" and just pass around the OleAutoObj instead?
  • if I abandon the notion of "Struct Shell", could I make a copy of function "create" called "RunCommand" and tweak it so it just runs the command and waits for it to finish?

-Louie

Re: DOORS to RTC work item calls
Mathias Mamsch - Tue Mar 26 15:41:20 EDT 2013

llandale - Tue Mar 26 12:02:31 EDT 2013
You know that win32Wait command has never worked for me.

I'm a little slow on the update here so don't be offended by these questions:

  • I can use this, with "wait = true", to replace win32Wait?
  • should not function "delete(Shell p)" also delete the OleAutoObj?
  • could not function "terminate(Shell x)" see if it already terminated?
  • What are the "ExitCode"s?
  • if the command has finished, will status(), exitCode(), and processID() still work?

  • Could you do away with "Struct Shell" and just pass around the OleAutoObj instead?
  • if I abandon the notion of "Struct Shell", could I make a copy of function "create" called "RunCommand" and tweak it so it just runs the command and waits for it to finish?

-Louie

Well it is really old code... Unfortunately code is not like cheese which gets better over time... Anyway to your questions:

  • win32SystemWait_ has always worked for me somehow. And yes you can replace it by the shell, to wait a certain time like win32SystemWait you would need to implement your own waiting routine.
  • It seems the Shell uses in most of the functions only the OleAutoObject as a property, so you could probably pass around the OleAutoObj. However you would have to store the command that has been issues somewhere else.
  • Yes the function delete(Shell p) should also close the oleAutoObject ...
  • Do determine if the process is still running you can use status(), to terminate it you could of course check the status beforehand.
  • The exit codes of the process is the integer number that is returned from the process. Normally 0 for no error and some error code for an error. It depends on the process you are calling. In dos batch you use %ERRORLEVEL% to check for the exit code.
  • I am not sure about the behaviour of processID() but status() and exitCode() are obviously supposed to work after the command has ended. You can find the description about the exec object here: http://msdn.microsoft.com/en-us/library/2f38xsxe%28v=vs.84%29.aspx

  • So yes you can also use it to just run a command and wait, but that is pretty much what 'system' does. You probably want to provide access to the io-streams. Notice that you can also send keys to the running program or do other interesting stuff than waiting while the command is running ;-)

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: DOORS to RTC work item calls
llandale - Tue Mar 26 15:53:02 EDT 2013

Mathias Mamsch - Tue Mar 26 15:41:20 EDT 2013
Well it is really old code... Unfortunately code is not like cheese which gets better over time... Anyway to your questions:

  • win32SystemWait_ has always worked for me somehow. And yes you can replace it by the shell, to wait a certain time like win32SystemWait you would need to implement your own waiting routine.
  • It seems the Shell uses in most of the functions only the OleAutoObject as a property, so you could probably pass around the OleAutoObj. However you would have to store the command that has been issues somewhere else.
  • Yes the function delete(Shell p) should also close the oleAutoObject ...
  • Do determine if the process is still running you can use status(), to terminate it you could of course check the status beforehand.
  • The exit codes of the process is the integer number that is returned from the process. Normally 0 for no error and some error code for an error. It depends on the process you are calling. In dos batch you use %ERRORLEVEL% to check for the exit code.
  • I am not sure about the behaviour of processID() but status() and exitCode() are obviously supposed to work after the command has ended. You can find the description about the exec object here: http://msdn.microsoft.com/en-us/library/2f38xsxe%28v=vs.84%29.aspx

  • So yes you can also use it to just run a command and wait, but that is pretty much what 'system' does. You probably want to provide access to the io-streams. Notice that you can also send keys to the running program or do other interesting stuff than waiting while the command is running ;-)

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

OK thanks. Your "create" does seem to work.

No, "system" returns as soon as the process is initiated which has forced me into a silly "wait for black window to close" ack following it; so I can display the results file of the command.

-Louie